var express = require("express");
var request = require('request');
var app = express();
var hostName = '127.0.0.1';
var port = 8080;
var api_prefix = 'http://api.jisuapi.com'
var appKey = 'f6e102f83ac0d89e';

app.use(express.static('public'));
app.get('/news/list', (req, res) => {
    console.log('/news/list');
    var options = {
        url: 'http://api.jisuapi.com/news/get?channel=%E5%A4%B4%E6%9D%A1&start=0&num=20&appkey=' + appKey,
        method: 'GET',
        json: true,
        headers: {"content-type": "application/json"}
    }
    request(options, function(error, response, body) {
        if (!error) {
            res.send(body)
        }
    }); 
})

app.listen(port,hostName,function(){
   console.log(`服务器运行在http://${hostName}:${port}`);
});